#ifndef DRAWLINKITEM_H
#define DRAWLINKITEM_H

#include <QObject>
#include <QGraphicsPolygonItem>
#include <QDebug>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>


class DrawLinkItem: public QObject, public QGraphicsPolygonItem
{
    Q_OBJECT

public:
    explicit DrawLinkItem(QObject *parent = nullptr);

    virtual ~DrawLinkItem()
    {
    }

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;

    void addPoint(const QPointF &point)
    {
        m_qvecRoadPoints.append(point);
    }

    virtual QPolygonF drawLinkAlogrithum(QPainter *painter);

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;

private:
    QVector<QPointF> m_qvecRoadPoints;
    bool m_bStart;

    QRectF m_qRecFBegin;
    QRectF m_qRecFEnd;

public slots:
    void setRect(QRectF);
};

#endif // DRAWLINKITEM_H
